package com.example.tester.mapper;

import com.example.tester.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

/**
 * @author lzh
 * @date 2019/9/9 - 11:20
 */
@Component
@Mapper
public interface StudentMapper {

    /**
     * 基于注解的mybatis用法
     * @param sno
     * @return
     */
    @Select("select * from student where sno=#{sno}")
    @Results(id = "student",value= {
            @Result(property = "sno", column = "sno", javaType = Integer.class),
            @Result(property = "sname", column = "sname", javaType = String.class),
            @Result(property = "ssex", column = "ssex", javaType = String.class)
    })
    Student queryStudentBySno(Integer sno);




    /**
     * 基于XML配置的mybatis用法
     * @param sno
     * @return
     */
    int deleteByPrimaryKey(Integer sno);

    int insert(Student record);

    int insertSelective(Student record);

    Student selectByPrimaryKey(Integer sno);

    int updateByPrimaryKeySelective(Student record);

    int updateByPrimaryKey(Student record);
}
